home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 January: Mac OS SDK / Dev.CD Jan 99 SDK1.toast / Development Kits / Interfaces&Libraries / Universal / Interfaces / CIncludes / ADSP.h next >
Encoding:
C/C++ Source or Header  |  1998-08-17  |  10.2 KB  |  279 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        ADSP.h
  3.  
  4.      Contains:    AppleTalk Data Stream Protocol (ADSP) Interfaces.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.2
  8.  
  9.      Copyright:    © 1986-1998, 1995-1997 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __ADSP__
  18. #define __ADSP__
  19.  
  20. #ifndef __ERRORS__
  21. #include <Errors.h>
  22. #endif
  23. #ifndef __APPLETALK__
  24. #include <AppleTalk.h>
  25. #endif
  26.  
  27.  
  28.  
  29. #if PRAGMA_ONCE
  30. #pragma once
  31. #endif
  32.  
  33. #ifdef __cplusplus
  34. extern "C" {
  35. #endif
  36.  
  37. #if PRAGMA_IMPORT
  38. #pragma import on
  39. #endif
  40.  
  41. #if PRAGMA_STRUCT_ALIGN
  42.     #pragma options align=mac68k
  43. #elif PRAGMA_STRUCT_PACKPUSH
  44.     #pragma pack(push, 2)
  45. #elif PRAGMA_STRUCT_PACK
  46.     #pragma pack(2)
  47. #endif
  48.  
  49. /*driver control csCodes*/
  50.  
  51. enum {
  52.     dspInit                        = 255,                            /* create a new connection end */
  53.     dspRemove                    = 254,                            /* remove a connection end */
  54.     dspOpen                        = 253,                            /* open a connection */
  55.     dspClose                    = 252,                            /* close a connection */
  56.     dspCLInit                    = 251,                            /* create a connection listener */
  57.     dspCLRemove                    = 250,                            /* remove a connection listener */
  58.     dspCLListen                    = 249,                            /* post a listener request */
  59.     dspCLDeny                    = 248,                            /* deny an open connection request */
  60.     dspStatus                    = 247,                            /* get status of connection end */
  61.     dspRead                        = 246,                            /* read data from the connection */
  62.     dspWrite                    = 245,                            /* write data on the connection */
  63.     dspAttention                = 244,                            /* send an attention message */
  64.     dspOptions                    = 243,                            /* set connection end options */
  65.     dspReset                    = 242,                            /* forward reset the connection */
  66.     dspNewCID                    = 241                            /* generate a cid for a connection end */
  67. };
  68.  
  69.  
  70. enum {
  71.                                                                 /* connection opening modes */
  72.     ocRequest                    = 1,                            /* request a connection with remote */
  73.     ocPassive                    = 2,                            /* wait for a connection request from remote */
  74.     ocAccept                    = 3,                            /* accept request as delivered by listener */
  75.     ocEstablish                    = 4                                /* consider connection to be open */
  76. };
  77.  
  78.  
  79. enum {
  80.                                                                 /* connection end states */
  81.     sListening                    = 1,                            /* for connection listeners */
  82.     sPassive                    = 2,                            /* waiting for a connection request from remote */
  83.     sOpening                    = 3,                            /* requesting a connection with remote */
  84.     sOpen                        = 4,                            /* connection is open */
  85.     sClosing                    = 5,                            /* connection is being torn down */
  86.     sClosed                        = 6                                /* connection end state is closed */
  87. };
  88.  
  89.  
  90. enum {
  91.                                                                 /* client event flags */
  92.     eClosed                        = 0x80,                            /* received connection closed advice */
  93.     eTearDown                    = 0x40,                            /* connection closed due to broken connection */
  94.     eAttention                    = 0x20,                            /* received attention message */
  95.     eFwdReset                    = 0x10                            /* received forward reset advice */
  96. };
  97.  
  98.  
  99. enum {
  100.                                                                 /* miscellaneous constants */
  101.     attnBufSize                    = 570,                            /* size of client attention buffer */
  102.     minDSPQueueSize                = 100                            /* Minimum size of receive or send Queue */
  103. };
  104.  
  105. /* connection control block */
  106. typedef struct TRCCB                     TRCCB;
  107. typedef TRCCB *                            TPCCB;
  108.  
  109. struct TRCCB {
  110.     TPCCB                             ccbLink;                    /* link to next ccb */
  111.     UInt16                             refNum;                        /* user reference number */
  112.     UInt16                             state;                        /* state of the connection end */
  113.     UInt8                             userFlags;                    /* flags for unsolicited connection events */
  114.     UInt8                             localSocket;                /* socket number of this connection end */
  115.     AddrBlock                         remoteAddress;                /* internet address of remote end */
  116.     UInt16                             attnCode;                    /* attention code received */
  117.     UInt16                             attnSize;                    /* size of received attention data */
  118.     void *                            attnPtr;                    /* ptr to received attention data */
  119.     UInt8                             reserved[220];                /* for adsp internal use */
  120. };
  121.  
  122. typedef CALLBACK_API( void , ADSPConnectionEventProcPtr )(TPCCB sourceCCB);
  123. /*
  124.     WARNING: ADSPConnectionEventProcPtr uses register based parameters under classic 68k
  125.              and cannot be written in a high-level language without 
  126.              the help of mixed mode or assembly glue.
  127. */
  128. typedef struct DSPParamBlock             DSPParamBlock;
  129. typedef DSPParamBlock *                    DSPPBPtr;
  130. typedef CALLBACK_API( void , ADSPCompletionProcPtr )(DSPPBPtr thePBPtr);
  131. /*
  132.     WARNING: ADSPCompletionProcPtr uses register based parameters under classic 68k
  133.              and cannot be written in a high-level language without 
  134.              the help of mixed mode or assembly glue.
  135. */
  136. typedef REGISTER_UPP_TYPE(ADSPConnectionEventProcPtr)             ADSPConnectionEventUPP;
  137. typedef REGISTER_UPP_TYPE(ADSPCompletionProcPtr)                 ADSPCompletionUPP;
  138.  
  139. struct TRinitParams {
  140.     TPCCB                             ccbPtr;                        /* pointer to connection control block */
  141.     ADSPConnectionEventUPP             userRoutine;                /* client routine to call on event */
  142.     UInt16                             sendQSize;                    /* size of send queue (0..64K bytes) */
  143.     void *                            sendQueue;                    /* client passed send queue buffer */
  144.     UInt16                             recvQSize;                    /* size of receive queue (0..64K bytes) */
  145.     void *                            recvQueue;                    /* client passed receive queue buffer */
  146.     void *                            attnPtr;                    /* client passed receive attention buffer */
  147.     UInt8                             localSocket;                /* local socket number */
  148.     UInt8                             filler1;                    /* filler for proper byte alignment */
  149. };
  150. typedef struct TRinitParams                TRinitParams;
  151.  
  152. struct TRopenParams {
  153.     UInt16                             localCID;                    /* local connection id */
  154.     UInt16                             remoteCID;                    /* remote connection id */
  155.     AddrBlock                         remoteAddress;                /* address of remote end */
  156.     AddrBlock                         filterAddress;                /* address filter */
  157.     UInt32                             sendSeq;                    /* local send sequence number */
  158.     UInt16                             sendWindow;                    /* send window size */
  159.     UInt32                             recvSeq;                    /* receive sequence number */
  160.     UInt32                             attnSendSeq;                /* attention send sequence number */
  161.     UInt32                             attnRecvSeq;                /* attention receive sequence number */
  162.     UInt8                             ocMode;                        /* open connection mode */
  163.     UInt8                             ocInterval;                    /* open connection request retry interval */
  164.     UInt8                             ocMaximum;                    /* open connection request retry maximum */
  165.     UInt8                             filler2;                    /* filler for proper byte alignment */
  166. };
  167. typedef struct TRopenParams                TRopenParams;
  168.  
  169. struct TRcloseParams {
  170.     UInt8                             abort;                        /* abort connection immediately if non-zero */
  171.     UInt8                             filler3;                    /* filler for proper byte alignment */
  172. };
  173. typedef struct TRcloseParams            TRcloseParams;
  174.  
  175. struct TRioParams {
  176.     UInt16                             reqCount;                    /* requested number of bytes */
  177.     UInt16                             actCount;                    /* actual number of bytes */
  178.     void *                            dataPtr;                    /* pointer to data buffer */
  179.     UInt8                             eom;                        /* indicates logical end of message */
  180.     UInt8                             flush;                        /* send data now */
  181. };
  182. typedef struct TRioParams                TRioParams;
  183.  
  184. struct TRattnParams {
  185.     UInt16                             attnCode;                    /* client attention code */
  186.     UInt16                             attnSize;                    /* size of attention data */
  187.     void *                            attnData;                    /* pointer to attention data */
  188.     UInt8                             attnInterval;                /* retransmit timer in 10-tick intervals */
  189.     UInt8                             filler4;                    /* filler for proper byte alignment */
  190. };
  191. typedef struct TRattnParams                TRattnParams;
  192.  
  193. struct TRstatusParams {
  194.     TPCCB                             statusCCB;                    /* pointer to ccb */
  195.     UInt16                             sendQPending;                /* pending bytes in send queue */
  196.     UInt16                             sendQFree;                    /* available buffer space in send queue */
  197.     UInt16                             recvQPending;                /* pending bytes in receive queue */
  198.     UInt16                             recvQFree;                    /* available buffer space in receive queue */
  199. };
  200. typedef struct TRstatusParams            TRstatusParams;
  201.  
  202. struct TRoptionParams {
  203.     UInt16                             sendBlocking;                /* quantum for data packets */
  204.     UInt8                             sendTimer;                    /* send timer in 10-tick intervals */
  205.     UInt8                             rtmtTimer;                    /* retransmit timer in 10-tick intervals */
  206.     UInt8                             badSeqMax;                    /* threshold for sending retransmit advice */
  207.     UInt8                             useCheckSum;                /* use ddp packet checksum */
  208. };
  209. typedef struct TRoptionParams            TRoptionParams;
  210.  
  211. struct TRnewcidParams {
  212.     UInt16                             newcid;                        /* new connection id returned */
  213. };
  214. typedef struct TRnewcidParams            TRnewcidParams;
  215.  
  216. struct DSPParamBlock {
  217.     QElem *                            qLink;
  218.     short                             qType;
  219.     short                             ioTrap;
  220.     Ptr                             ioCmdAddr;
  221.     ADSPCompletionUPP                 ioCompletion;
  222.     OSErr                             ioResult;
  223.     StringPtr                         ioNamePtr;
  224.     short                             ioVRefNum;
  225.     short                             ioCRefNum;                    /* adsp driver refNum */
  226.     short                             csCode;                        /* adsp driver control code */
  227.     long                             qStatus;                    /* adsp internal use */
  228.     short                             ccbRefNum;
  229.     union {
  230.         TRinitParams                     initParams;
  231.         TRopenParams                     openParams;
  232.         TRcloseParams                     closeParams;            /*dspClose, dspRemove*/
  233.         TRioParams                         ioParams;                /*dspRead, dspWrite*/
  234.         TRattnParams                     attnParams;                /*dspAttention*/
  235.         TRstatusParams                     statusParams;            /*dspStatus*/
  236.         TRoptionParams                     optionParams;            /*dspOptions*/
  237.         TRnewcidParams                     newCIDParams;            /*dspNewCID*/
  238.     }                                 u;
  239. };
  240.  
  241. enum { uppADSPConnectionEventProcInfo = 0x0000B802 };             /* register no_return_value Func(4_bytes:A1) */
  242. enum { uppADSPCompletionProcInfo = 0x00009802 };                 /* register no_return_value Func(4_bytes:A0) */
  243. #define NewADSPConnectionEventProc(userRoutine)                 (ADSPConnectionEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPConnectionEventProcInfo, GetCurrentArchitecture())
  244. #define NewADSPCompletionProc(userRoutine)                         (ADSPCompletionUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppADSPCompletionProcInfo, GetCurrentArchitecture())
  245. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  246.     #pragma parameter CallADSPConnectionEventProc(__A0, __A1)
  247.     void CallADSPConnectionEventProc(ADSPConnectionEventUPP routine, TPCCB sourceCCB) = 0x4E90;
  248. #else
  249.     #define CallADSPConnectionEventProc(userRoutine, sourceCCB)  CALL_ONE_PARAMETER_UPP((userRoutine), uppADSPConnectionEventProcInfo, (sourceCCB))
  250. #endif
  251. #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  252.     #pragma parameter CallADSPCompletionProc(__A1, __A0)
  253.     void CallADSPCompletionProc(ADSPCompletionUPP routine, DSPPBPtr thePBPtr) = 0x4E91;
  254. #else
  255.     #define CallADSPCompletionProc(userRoutine, thePBPtr)         CALL_ONE_PARAMETER_UPP((userRoutine), uppADSPCompletionProcInfo, (thePBPtr))
  256. #endif
  257.  
  258.  
  259. #if PRAGMA_STRUCT_ALIGN
  260.     #pragma options align=reset
  261. #elif PRAGMA_STRUCT_PACKPUSH
  262.     #pragma pack(pop)
  263. #elif PRAGMA_STRUCT_PACK
  264.     #pragma pack()
  265. #endif
  266.  
  267. #ifdef PRAGMA_IMPORT_OFF
  268. #pragma import off
  269. #elif PRAGMA_IMPORT
  270. #pragma import reset
  271. #endif
  272.  
  273. #ifdef __cplusplus
  274. }
  275. #endif
  276.  
  277. #endif /* __ADSP__ */
  278.  
  279.